package com.shop2cn.iapi.sellerpromotion.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.grouponmgr.parameter.SaveGrouponReq;
import com.shop2cn.iapi.sellerpromotion.parameter.CreatePromotionBean;
import com.shop2cn.iapi.sellerpromotion.parameter.PromotionItem;
import com.shop2cn.iapi.sellerpromotion.service.CreatePromotionCall;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymatou.iapi.marketingmanage.parameter.CreateSellerPromotionBean;
import com.ymatou.iapi.marketingmanage.parameter.PromotionValue;
import com.ymatou.iapi.trading.operate.parameter.enums.PromotionTypeEnum;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.AgentProductCallService;
import com.ymttest.business.service.Shop2cnGrouponCallService;
import com.ymttest.business.service.Shop2cnSellerPromotionCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.mongo.Shop2cnSellerPromotionInfoWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
/**
*创建满减
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CreatePromotion{
	private static CreatePromotionBean createpromotionBean;
	private static CreatePromotionCall createpromotionCall;
	private static Integer mchId;
	private static Shop2cnSellerPromotionInfoWapper Shop2cnSellerPromotionInfoWapper;
	private static boolean autoend=true;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("创建满减");
		try {
			Shop2cnSellerPromotionInfoWapper=new Shop2cnSellerPromotionInfoWapper();
			mchId=GodmchManageCallService.CreateSellerMch();
		} catch (Exception e) {
		}
	}

	@Before
	public void caseUp() {
		createpromotionBean=new CreatePromotionBean();
		createpromotionCall=new CreatePromotionCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(createpromotionCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
		if(autoend) {
			try {
				Shop2cnSellerPromotionCallService.EndAllEnablePromotion(mchId);
			} catch (IOException e) {
			//			e.printStackTrace();
			}
		}
	}
	private void verifyDB(Integer promotionId, CreatePromotionBean createpromotionBean2) throws Exception {
		Map m = Shop2cnSellerPromotionInfoWapper.getPromotionById(promotionId);
		if (m != null && m.get("sid") != null) {
			Logger.verifyEquals(createpromotionBean2.getSellerId(), m.get("sid"), "验证SellerId");
			Logger.verifyEquals(createpromotionBean2.getName(), m.get("name"), "验证name");
			//新增 20200729 是否显示在首页
			Logger.verifyEquals(createpromotionBean2.getShowHomePage(), (boolean)m.get("shp"), "验证shp");
//			Logger.verifyEquals(createpromotionBean2.getPromotionInfo().getPromotionDesc(), m.get("des"), "验证des");
			if (createpromotionBean2.getBegin().compareTo(YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDHMS)) > 0) {
				Logger.verifyEquals(createpromotionBean2.getBegin().substring(0, 16),
						YMTDateUtil.getFromDTSDate(m.get("bt").toString(), YMTDateUtil.YMDHMS).substring(0, 16), "验证bt");
			} else {
				Logger.verifyNotNull(YMTDateUtil.getFromDTSDate(m.get("bt").toString(), YMTDateUtil.YMDHMS), "验证bt");
			}

			Logger.verifyEquals(createpromotionBean2.getEnd().substring(0, 16),
					YMTDateUtil.getFromDTSDate(m.get("et").toString(), YMTDateUtil.YMDHMS).substring(0, 16), "验证et");
			//SameProductUse默认值为false
			if(createpromotionBean2.getSameProductUse()==null) {
				Logger.verifyEquals(false, m.get("issp"), "验证issameproduct");
			}
			else {
				Logger.verifyEquals(createpromotionBean2.getSameProductUse(), m.get("issp"), "验证issameproduct");
			}
			Logger.verifyEquals(createpromotionBean2.getType(), m.get("type"), "验证type");
			
			// 1：全场商品 2：指定商品 
			if (createpromotionBean2.getProductIdList()==null||createpromotionBean2.getProductIdList().size()<=0) {
				Logger.verifyEquals(1, m.get("pjm"), "验证pjm");
			} else
				Logger.verifyEquals(2, m.get("pjm"), "验证pjm");
			}
			// 未操作
			Logger.verifyEquals(0, m.get("em"), "验证em");
			List<Map> lm = (List<Map>) m.get("vs");
			List<PromotionItem> pvl = createpromotionBean2.getPromotionItemList();
			Logger.verifyEquals(lm.size(), pvl.size(), "验证PromotionValueSize");
			int mytype = 0;
			if (PromotionTypeEnum.HalfIfCountEnough.getCode() == createpromotionBean2.getType() || PromotionTypeEnum.DiscountIfCountEnough.getCode() == createpromotionBean2.getType()
					|| PromotionTypeEnum.ReduceIfCountEnough.getCode() == createpromotionBean2.getType()) {
				// 满件
				Logger.debug("满件活动");
				mytype = 1;
			} else {
				// 满额
				Logger.debug("满额活动");
				mytype = 2;
			}
			// 多个验证
			for (PromotionItem promotionValue : pvl) {
				if (mytype == 1) {
					BigDecimal s = promotionValue.getUseCondition().setScale(2);
					BigDecimal v = promotionValue.getValue();
					for (Map tm : lm) {
						if (s.setScale(2).equals(BigDecimal.valueOf(Double.valueOf(tm.get("rv").toString())).setScale(2))) {
							verifyPromotionValue(createpromotionBean2.getType(), tm, promotionValue);
						}
						
						verifyFreeFreight(tm);
						
					}
				} else if (mytype == 2) {
					BigDecimal s = promotionValue.getUseCondition();
					BigDecimal v = promotionValue.getValue();
					for (Map tm : lm) {
						if (s.setScale(2).equals(new BigDecimal(tm.get("rv").toString()).setScale(2))) {
							verifyPromotionValue(createpromotionBean2.getType(), tm, promotionValue);
						}
						
						verifyFreeFreight(tm);
						
					}
				}
			}
			

			List<Map> psm = (List<Map>) m.get("ps");
			if (psm != null) {
				for (Map map : psm) {
					Logger.verifyNotNull(map.get("pidg"), "验证pidg");
					Logger.verifyNotNull(map.get("pidn"), "验证pidn");
					//这个字段目前没用
//					Logger.verifyNotEquals(0,map.get("pidn"), "验证pidn非0");
				}
				List<String> temppids = createpromotionBean2.getProductIdList();
				List<String> pids=new ArrayList<>();
				for (String string : temppids) {
					if(!pids.contains(string)){
						pids.add(string);
					}
				}
				Logger.verifyEquals(pids.size(), psm.size(), "验证PromotionValueSize");
				for (String pid : pids) {
					Logger.verifyIsContains(pid, psm.toString(), "验证包含pid");
				}
			}
           //新增 20200810
		   Logger.verifyEquals(createpromotionBean.getBannerUrl(), m.get("bn"), "验证bn");
		   Logger.verifyEquals(createpromotionBean.getBgColor(), m.get("bgc"), "验证bgc");
		   Logger.verifyEquals(createpromotionBean.getTitleColor(), m.get("tc"), "验证tc");
		   
		}
	private void verifyPromotionValue(int type, Map m, PromotionItem promotionValue) {
		if (type == 1) {
			Logger.verifyEquals(promotionValue.getUseCondition().toString(), m.get("rv").toString(), "验证rv");
			Logger.verifyEquals(promotionValue.getValue(), new BigDecimal(m.get("dv").toString()), "验证dv");

		}
		// 折扣的时候/10
		else if (type == 2) {
			Logger.verifyEquals(promotionValue.getUseCondition().toString(), m.get("rv").toString(), "验证rv");
			Logger.verifyEquals(promotionValue.getValue().divide(BigDecimal.valueOf(10)), new BigDecimal(m.get("dv").toString()), "验证dv");

		} else if (type == 3) {
			Logger.verifyEquals(promotionValue.getUseCondition(), new BigDecimal(m.get("rv").toString()), "验证rv");
			Logger.verifyEquals(promotionValue.getValue(), new BigDecimal(m.get("dv").toString()), "验证dv");
		} else if (type == 4) {
			Logger.verifyEquals(promotionValue.getUseCondition(), new BigDecimal(m.get("rv").toString()), "验证rv");
			Logger.verifyEquals(promotionValue.getValue().divide(BigDecimal.valueOf(10)), new BigDecimal(m.get("dv").toString()), "验证dv");

		} else if (type == 5) {
			Logger.verifyEquals("2", m.get("rv").toString(), "验证rv");
			Logger.verifyEquals(new BigDecimal(0.5), new BigDecimal(m.get("dv").toString()), "验证dv");

		}
	}
	
	/**
	 * 验证是否包邮 及包邮地区  summing 20191227新增 
	 * @param tm
	 */
    private void verifyFreeFreight(Map tm) {
		//验证是否包邮
		if(createpromotionBean.getPromotionItemList().size()>0 && createpromotionBean.getPromotionItemList().get(0).getfreeFreight()!=null)
		   Logger.verifyEquals(createpromotionBean.getPromotionItemList().get(0).getfreeFreight(), tm.get("ff"), "验证是否包邮ff");
		else 
		   Logger.verifyEquals(false, tm.get("ff"), "验证是否包邮ff");
		//包邮区域
		if(createpromotionBean.getFreeRegions()!=null && createpromotionBean.getFreeRegions().size()>0)
			if(createpromotionBean.getFreeRegions().size()==1)
		       Logger.verifyEquals(createpromotionBean.getPromotionItemList().get(0).getFreeRegions(), tm.get("rg"), "验证包邮区域rg");
			else if(createpromotionBean.getFreeRegions().size()==2)
			  Logger.verifyEquals(createpromotionBean.getPromotionItemList().get(1).getFreeRegions(), tm.get("rg"), "验证包邮区域rg");
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_001() {
		Logger.start(true,"创建满减成功,满额减3");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10.5));
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_002() {
		Logger.start(true,"创建满减成功,满额折4");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_003() {
		Logger.start(true,"创建满减成功,满件减1");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_004() {
		Logger.start(true,"创建满减成功,满件折2");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_005() {
		Logger.start(true,"创建满减成功,外币币种USD");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setCurrency("USD");
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_006() {
		Logger.start(true,"创建满减成功,不支持同商品满减");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setSameProductUse(false);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_007() {
		Logger.start(true,"创建满减成功,多层级满减规则-,满件减1");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(20));
			createpromotionBean.getPromotionItemList().add(e);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_008() {
		Logger.start(true,"不输入sellerid失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setSellerId(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_009() {
		Logger.start(true,"不输入name失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setName(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_010() {
		Logger.start(true,"不输入begin失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_011() {
		Logger.start(true,"不输入end失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setEnd(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_012() {
		Logger.start(true,"不输入type失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setType(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_013() {
		Logger.start(true,"输入错误type失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setType(-1);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_014() {
		Logger.start(true,"不输入currency失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setCurrency(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_015() {
		Logger.start(true,"不输入sameProductUse失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setSameProductUse(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_016() {
		Logger.start(true,"不输入promotionItemList失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setPromotionItemList(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_017() {
		Logger.start(true,"输入指定productIdList成功");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_018() {
		Logger.start(true,"重复调用创建失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Thread.sleep(1000);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_019() {
		//TODO 待确认 begin时间？
		Logger.start(true,"begin小于当前时间创建成功begin取当前时间");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(-1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_020() {
		Logger.start(true,"end小于begin失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_021() {
		Logger.start(true,"创建2场同商品满减活动,时间不冲突成功");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_022() {
		Logger.start(true,"创建2场同商品满减活动,时间冲突失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_023() {
		Logger.start(true,"创建2场同时间满减活动,商品不冲突成功");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			AddAgentProductBean addAgentProductBean2 = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId2 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean2);
			List<String> productIdList2=new ArrayList<String>();
			productIdList2.add(productId2);
			createpromotionBean.setProductIdList(productIdList2);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId2=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId2, createpromotionBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_024() {
		Logger.start(true,"创建2场同时间满减活动,商品冲突失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			AddAgentProductBean addAgentProductBean2 = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId2 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean2);
			List<String> productIdList2=new ArrayList<String>();
			//商品冲突
			productIdList2.add(productId);
			productIdList2.add(productId2);
			createpromotionBean.setProductIdList(productIdList2);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_025() {
		Logger.start(true,"创建2场同时间全场满减活动,失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	@Ignore
	//不判断level
	public void Tc_CreatePromotion_026() {
		Logger.start(true,"promotionItemList.level为空失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setLevel(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_027() {
		Logger.start(true,"promotionItemList.useCondition为空失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreatePromotion_028() {
		Logger.start(true,"promotionItemList.value为空失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setValue(null);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	@Ignore
	//不判断level
	public void Tc_CreatePromotion_029() {
		Logger.start(true,"promotionItemList.level负数失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setLevel(-1);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_030() {
		Logger.start(true,"promotionItemList.useCondition负数失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(-1));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_031() {
		Logger.start(true,"promotionItemList.value负数失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(-1));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_032() {
		Logger.start(true,"满额折4promotionItemList.value大于等于9.9失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_033() {
		Logger.start(true,"满件折2promotionItemList.value大于等于9.9失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_034() {
		Logger.start(true,"创建满额减3promotionItemList.value大于等于promotionItemList.useCondition,失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	@Ignore
	//满件减无法判断 多少件减多少元的控制
	public void Tc_CreatePromotion_035() {
		Logger.start(true,"创建满件减1promotionItemList.value大于等于promotionItemList.useCondition,失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_036() {
		Logger.start(true,"创建外币JPY满额减3promotionItemList.value有小数点失败");
		try {
			Integer mchId2 = GodmchManageCallService.CreateCountrySellerMch("JPN");
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 3);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(1.1));
			createpromotionBean.setCurrency("JPY");
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyIsContains("不支持小数点", createpromotionCall.getString("message"), "验证message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	@Ignore
	public void Tc_CreatePromotion_037() {
		Logger.start(true,"创建满件减1多层级level2优惠小于level1(1:2件-10,2:3件-5)失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean.getPromotionItemList().clear();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(2));
			e.setValue(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().add(e);
			
			PromotionItem e2=new PromotionItem();
			e2.setLevel(2);
			e2.setUseCondition(BigDecimal.valueOf(3));
			e2.setValue(BigDecimal.valueOf(5));
			createpromotionBean.getPromotionItemList().add(e2);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	@Ignore
	public void Tc_CreatePromotion_038() {
		Logger.start(true,"创建满件折2多层级level2优惠小于level1(1:2件8折,2:3件9折)失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);
			createpromotionBean.getPromotionItemList().clear();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(2));
			e.setValue(BigDecimal.valueOf(8));
			createpromotionBean.getPromotionItemList().add(e);
			
			PromotionItem e2=new PromotionItem();
			e2.setLevel(2);
			e2.setUseCondition(BigDecimal.valueOf(3));
			e2.setValue(BigDecimal.valueOf(9));
			createpromotionBean.getPromotionItemList().add(e2);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_039() {
		Logger.start(true,"创建满减成功,多层级满减规则,满件折2");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);
			createpromotionBean.getPromotionItemList().clear();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(2));
			e.setValue(BigDecimal.valueOf(8));
			createpromotionBean.getPromotionItemList().add(e);
			
			PromotionItem e2=new PromotionItem();
			e2.setLevel(2);
			e2.setUseCondition(BigDecimal.valueOf(3));
			e2.setValue(BigDecimal.valueOf(7));
			createpromotionBean.getPromotionItemList().add(e2);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_040() {
		Logger.start(true,"创建外币JPY满额减3,商家不支持对应币种失败");
		try {
			Integer mchId2 = GodmchManageCallService.CreateCountrySellerMch("USD");
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 3);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(1.1));
			createpromotionBean.setCurrency("JPY");
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyIsContains("币种不存在", createpromotionCall.getString("message"), "验证message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_041() {
		Logger.start(true,"创建满减成功,多层级满减规则-,满件减1-多层级依靠level排序");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			PromotionItem e=new PromotionItem();
			e.setLevel(3);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(20));
			createpromotionBean.getPromotionItemList().add(e);
			
			PromotionItem e2=new PromotionItem();
			e2.setLevel(2);
			e2.setUseCondition(BigDecimal.valueOf(150));
			e2.setValue(BigDecimal.valueOf(15));
			createpromotionBean.getPromotionItemList().add(e2);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			//TODO 这个排序需要前端接口校验
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_042() {
		Logger.start(true,"创建满件减1,UseCondition为小数时失败");
		//件数不能为小数
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(1.5));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyEquals("满件使用条件不支持小数", createpromotionCall.getString("message"), "message返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_043() {
		Logger.start(true,"创建外币JPY满额减3promotionItemList.UseCondition有小数点失败");
		try {
			Integer mchId2 = GodmchManageCallService.CreateCountrySellerMch("JPN");
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 3);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10.1));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(1));
			createpromotionBean.setCurrency("JPY");
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyIsContains("不支持小数点", createpromotionCall.getString("message"), "验证message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_CreatePromotion_044() {
		Logger.start(true,"业务测试数据创建-执行时需要注销caseDown");
		try {
			autoend=false;
			int mchId2=500213064;
//			p2421565    日币
//			p2421567    日币
//			p2421570    日币
//			p2421575    日币
			String pid="p2421565";
			String pid2="p2421567";
			String pid3="p2421570";
			String pid4="p2421575";
			PromotionItem e=new PromotionItem();
			Integer promotionId;
			String cur="JPY";
			//1：满件减2：满件折3：满额减4：满额折
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 2);
			createpromotionBean.setCurrency(cur);
			createpromotionBean.setProductIdList(Arrays.asList(pid,pid2,pid3,pid4));
			createpromotionBean.setSameProductUse(true);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(2));
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(5));
			e.setValue(BigDecimal.valueOf(8));
			createpromotionBean.getPromotionItemList().add(e);
			createpromotionBean.setCurrency(cur);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			createpromotionBean.getPromotionItemList().forEach(pi->{
				createpromotionBean.getProductIdList().forEach(p->{
					Logger.debug("productid:"+p+":满"+pi.getUseCondition()+"件折"+pi.getValue());
				});
				
			});
			
//			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 2);
//			createpromotionBean.setCurrency(cur);
//			createpromotionBean.setProductIdList(Arrays.asList(pid2));
//			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(2));
//			e=new PromotionItem();
//			e.setLevel(2);
//			e.setUseCondition(BigDecimal.valueOf(6));
//			e.setValue(BigDecimal.valueOf(8));
//			createpromotionBean.getPromotionItemList().add(e);
//			createpromotionCall.setData(createpromotionBean);
//			createpromotionCall.callService();			
//			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
//			promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
//			createpromotionBean.getPromotionItemList().forEach(pi->{
//				Logger.debug("productid:"+createpromotionBean.getProductIdList().get(0)+":满"+pi.getUseCondition()+"件折"+pi.getValue());
//			});
//			
//			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 3);
//			createpromotionBean.setCurrency(cur);
//			createpromotionBean.setProductIdList(Arrays.asList(pid3));
//			e=new PromotionItem();
//			e.setLevel(2);
//			e.setUseCondition(BigDecimal.valueOf(200));
//			e.setValue(BigDecimal.valueOf(20));
//			createpromotionBean.getPromotionItemList().add(e);
//			createpromotionCall.setData(createpromotionBean);
//			createpromotionCall.callService();			
//			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
//			promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
//			createpromotionBean.getPromotionItemList().forEach(pi->{
//				Logger.debug("productid:"+createpromotionBean.getProductIdList().get(0)+":满"+pi.getUseCondition()+"额减"+pi.getValue());
//			});
//			
//			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 4);
//			createpromotionBean.setCurrency(cur);
//			createpromotionBean.setProductIdList(Arrays.asList(pid4));
//			e=new PromotionItem();
//			e.setLevel(2);
//			e.setUseCondition(BigDecimal.valueOf(200));
//			e.setValue(BigDecimal.valueOf(8));
//			createpromotionBean.getPromotionItemList().add(e);
//			createpromotionCall.setData(createpromotionBean);
//			createpromotionCall.callService();			
//			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
//			promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
//			createpromotionBean.getPromotionItemList().forEach(pi->{
//				Logger.debug("productid:"+createpromotionBean.getProductIdList().get(0)+":满"+pi.getUseCondition()+"额折"+pi.getValue());
//			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_CreatePromotion_045() {
		Logger.start(true,"创建限时抢活动和全场满减冲突失败(修改20200324解除冲突)");
		try {
			//创建限时抢活动
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId,"AutoTest",false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId,pid);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(mchId, pid, catalogList);

			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyIsContains(initProductaddactivity.getName(), createpromotionCall.getString("message"), "验证和神器限时抢活动冲突");
			//限时折扣-终止活动
			AgentProductCallService.endactivity(mchId,activityId);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_CreatePromotion_046() {
		Logger.start(true,"创建限时抢活动和指定满减冲突失败(修改20200324解除冲突)");
		try {
			//创建限时抢活动
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId,"AutoTest",false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId,pid);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(mchId, pid, catalogList);

			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setProductIdList(Arrays.asList(pid));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyIsContains(initProductaddactivity.getName(), createpromotionCall.getString("message"), "验证和神器限时抢活动冲突");
			//限时折扣-终止活动
			AgentProductCallService.endactivity(mchId,activityId);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_047() {
		Logger.start(true,"创建限时抢活动和指定满减商品不冲突时间冲突,可以创建");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId,"AutoTest",false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			String pid2=TestDataManager.getRandomUUID().toString();
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId,pid);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(mchId, pid, catalogList);
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setProductIdList(Arrays.asList(pid2));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			//限时折扣-终止活动
			AgentProductCallService.endactivity(mchId,activityId);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
//	@Ignore
	public void Tc_CreatePromotion_048() {
		Logger.start(true,"创建2场同商品满减活动,时间冲突失败-bug");
		try {
			//创建p1 p2活动 再创建 p3 p4 活动 再创建p1 p2 活动 会通过的bug
            String p1 = TestDataManager.getRandomUUID().toString();
            String p2 = TestDataManager.getRandomUUID().toString();
            String p3 = TestDataManager.getRandomUUID().toString();
            String p4 = TestDataManager.getRandomUUID().toString();
            
            createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
            
			createpromotionBean.setProductIdList(Arrays.asList(p1,p2));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();		
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			
			createpromotionBean.setProductIdList(Arrays.asList(p3,p4));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();		
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			
			createpromotionBean.setProductIdList(Arrays.asList(p1,p2));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();		
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			
			createpromotionBean.setProductIdList(Arrays.asList(p3,p4));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();		
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			
			createpromotionBean.setProductIdList(Arrays.asList(p1,p3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();		
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_049() {
		Logger.start(true,"创建满减币种不存在失败");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setCurrency("ENY");
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyEquals("币种不存在", createpromotionCall.getString("message"), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_050() {
		Logger.start(true,"创建满减-满件减不支持小数");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(1.5));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyEquals("满件使用条件不支持小数", createpromotionCall.getString("message"), "验证返回");
			
			createpromotionBean.setType(2);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(9));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyEquals("满件使用条件不支持小数", createpromotionCall.getString("message"), "验证返回");
			Thread.sleep(500);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P2.class})
	@TestCase
	@Ignore
	public void Tc_CreatePromotion_051() {
		Logger.start(true,"创建满减活动,商品和拼团冲突(修改20200324解除冲突)");
		try {
			
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			//Shop2cnSellerPromotionCallService.EndAllEnablePromotion(mchId);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId,"AutoTest",false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId,pid);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			
			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid, catalogList.get(0), 100d);
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(pid);
			createpromotionBean.setProductIdList(productIdList);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
//			createpromotionBean.setProductIdList(productIdList);
//			createpromotionCall.callService();			
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_052() {
		Logger.start(true,"创建满减成功,全国包邮");
		try {
			//mchId=500415805;
			//Shop2cnSellerPromotionCallService.EndAllEnablePromotion(mchId);
			
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10.5));
			
			createpromotionBean.getPromotionItemList().get(0).setfreeFreight(true);

			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_053() {
		Logger.start(true,"创建满减成功,一个地区包邮-上海包邮");
		try {
			//mchId=500415806;
			//Shop2cnSellerPromotionCallService.EndAllEnablePromotion(mchId);
			
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10.5));
			
			List<String> freeRegions=new ArrayList<>();
			freeRegions.add("上海");
			createpromotionBean.getPromotionItemList().get(0).setfreeFreight(true);
			createpromotionBean.getPromotionItemList().get(0).setFreeRegions(freeRegions);

			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_054() {
		Logger.start(true,"创建满减成功,两个地区包邮-上海、北京包邮");
		try {
			//mchId=500415807;
			//Shop2cnSellerPromotionCallService.EndAllEnablePromotion(mchId);
			
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10.5));
			
			List<String> freeRegions=new ArrayList<>();
			freeRegions.add("上海");
			freeRegions.add("北京");
			createpromotionBean.getPromotionItemList().get(0).setfreeFreight(true);
			createpromotionBean.getPromotionItemList().get(0).setFreeRegions(freeRegions);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_055() {
		Logger.start(true,"创建满减成功,多层级满减规则-,满件减1-使用条件2比使用条件1要大(level1:100 ,level2:200)-成功");
		try {
		   //新增 2020-01-03 summing 之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);//满件减
			
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(20));
			createpromotionBean.getPromotionItemList().add(e);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_056() {
		Logger.start(true,"创建满减成功,多层级满减规则-,满件减1-使用条件2比使用条件1要小(level1:100 ,level2:50)-失败");
		try {
			//新增 2020-01-03 summing 之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);//满件减
			
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(50));
			e.setValue(BigDecimal.valueOf(20));
			createpromotionBean.getPromotionItemList().add(e);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, createpromotionCall.getString("message").contains("层级2必须比层级1的使用条件大"), "验证返回message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_057() {
		Logger.start(true,"创建满减成功,多层级满减规则-,满件减1-使用条件2比使用条件1要大-(level1:100 ,level2:200)-成功");
		try {
			//新增 2020-01-03 summing 之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);//满件折
			
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(8));
			createpromotionBean.getPromotionItemList().add(e);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_058() {
		Logger.start(true,"创建满减成功,多层级满减规则-,满件减1-使用条件2比使用条件1要小(level1:100 ,level2:50)-失败");
		try {
			//新增 2020-01-03 summing 之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);//满件折
			
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(50));
			e.setValue(BigDecimal.valueOf(5));
			createpromotionBean.getPromotionItemList().add(e);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, createpromotionCall.getString("message").contains("层级2必须比层级1的使用条件大"), "验证返回message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_059() {
		Logger.start(true,"创建满减成功,满件折2-使用条件2比使用条件1要大(level1:100 ,level2:200)-成功");
		try {
			//新增 2020-01-03 summing 之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);//满额减
			
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(5));
			
			createpromotionBean.getPromotionItemList().add(e);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_060() {
		Logger.start(true,"创建满减成功,满件折2-使用条件2比使用条件1要小(level1:100 ,level2:50)-失败");
		try {
			//新增 2020-01-03 summing 之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);//满额减
			
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(50));
			e.setValue(BigDecimal.valueOf(20));
			
			createpromotionBean.getPromotionItemList().add(e);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, createpromotionCall.getString("message").contains("层级2必须比层级1的使用条件大"), "验证返回message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_061() {
		Logger.start(true,"创建满减成功,满件折2-使用条件2比使用条件1要大(level1:100 ,level2:200)-成功");
		try {
			//新增 2020-01-03 summing 之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);//满额折
			
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(9.9));
			
			createpromotionBean.getPromotionItemList().add(e);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_062() {
		Logger.start(true,"创建满减成功,满件折2-使用条件2比使用条件1要小(level1:100 ,level2:50)-失败");
		try {
			//新增 2020-01-03 summing 之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);//满额折
			
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(50));
			e.setValue(BigDecimal.valueOf(7));
			
			createpromotionBean.getPromotionItemList().add(e);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, createpromotionCall.getString("message").contains("层级2必须比层级1的使用条件大"), "验证返回message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreatePromotion_063() {
		Logger.start(true,"创建满减成功,满件折2-使用条件2比使用条件1要小(level1:100 ,level2:50)-包邮-失败");
		try {
			//新增 2020-01-03 summing 之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);//满额折
			
			List<String> freeRegions=new ArrayList<>();
			freeRegions.add("上海");
			freeRegions.add("北京");
			createpromotionBean.getPromotionItemList().get(0).setfreeFreight(true);
			createpromotionBean.getPromotionItemList().get(0).setFreeRegions(freeRegions);
			
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(50));
			e.setValue(BigDecimal.valueOf(7));
			
			createpromotionBean.getPromotionItemList().add(e);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("400", createpromotionCall.getString("code"), "验证返回");
			Logger.verifyEquals(true, createpromotionCall.getString("message").contains("层级2必须比层级1的使用条件大"), "验证返回message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_064() {
		Logger.start(true,"创建满减成功,满额减3,是否显示在首页ShowHomePage=true");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10.5));
			createpromotionBean.setShowHomePage(true);
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_065() {
		Logger.start(true,"创建满减成功,满额减3,是否显示在首页ShowHomePage=false");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10.5));
			createpromotionBean.setShowHomePage(false);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();	
			
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();	
			
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(5,"yyyy-MM-dd HH:mm:ss"));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreatePromotion_066() {
		Logger.start(true,"创建满减成功,新增banner url、背景颜色、标题颜色 20200810");
		try {
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBannerUrl("落地页banner_"+TestDataManager.getRandomIntNum(5));
			createpromotionBean.setBgColor("背景颜色_"+TestDataManager.getRandomIntNum(5));
			createpromotionBean.setTitleColor("标题颜色_"+TestDataManager.getRandomIntNum(5));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(10.5));
			
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
			verifyDB(promotionId, createpromotionBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}